<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>Document</title>
    <script src="/lib/vue.js"></script>
    <style>
      .red {
        background-color: red;
      }
      .font {
        font-size: 20px;
      }
      .strong {
        color: white;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- d动态切换：Vue.set(vm.classobj,"strong",true) -->
      <div :class="classobj">动态切换class对象写法</div>
      <!-- vm.classarray.push("strong") -->
      <div :class="classarray">动态切换class数组写法</div>
    </div>
    <script>
      var vm = new Vue({
        el: "#app",
        data() {
          return {
            classobj: {
              red: true,
            },
            classarray: ["red"],
          };
        },
      });
    </script>
  </body>
</html>
